//###############
//FILE : NameRemoveFileSession.java
//WRITER : Daniel Lowengrub, daniel_i_l, 320687098
//EXERCISE : oop ex3 2011
//DESCRIPTION:
//See below
//###############

package oop.ex3.protocol.sessions;

import oop.ex3.protocol.messages.DontContainFileMsg;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import oop.ex3.exceptions.InvalidMessageException;

/**
 * Get a removed file notification from a FM.
 * @author daniel
 */
public class NameRemoveFileSession extends NameToFileSession {
    private String _fileName;

    /**
	 * Create a new session.
	 */
    public NameRemoveFileSession() {
        super(new DontContainFileMsg());
    }

    /**
     * Get the name of the file that was removed.
     * @return The file name.
     */
    public String getFileName() {
        return _fileName;
    }

    @Override
    protected boolean specExecuteSession(DataInputStream inputStream, DataOutputStream outputStream) throws IOException, InvalidMessageException {
        DontContainFileMsg dontContainFile = new DontContainFileMsg();
        dontContainFile.receive(inputStream);

        _fileName = dontContainFile.getFileName();

        _done.send(outputStream);

        return true;
    }

}
